<script type="text/javaScript">
    // <![CDATA[    
    
    $(document).ready(function() {
        $('#novoDiv').hide();
        
        /*
        $('#novoForm').submit(function() {
            return false;
        });
         */
                
        $('#novoUtilA').click(function(){
            $('#novoDiv').dialog({ modal: true });
        }); 
        
        //$('#adicionar').click(function(){
        $('#novoForm').submit(function() {
            var ok_user = validateField($("#utilizador"), $('#novoDivMsgBox'));
            var ok_pass = validateField($("#password"), $('#novoDivMsgBox'));
            var ok_pass2 = validateField($("#password2"), $('#novoDivMsgBox'));
            
            if (ok_user && ok_pass && ok_pass2){
                $('#novoDivMsgBox').text('');
                if ($('#password').val() != $('#password2').val()){
                    $('#novoDivMsgBox').text('passwords tem que ser iguais');
                    $('#password').addClass("redborder");
                    $('#password2').addClass("redborder");
                    return false;
                } else {
                    $('#novoDivMsgBox').text('');
                    $('#password').removeClass("redborder");
                    $('#password2').removeClass("redborder");  
                }
            } else {
                $('#novoDivMsgBox').text("Todos os campos tem que ser preenchidos");
                return false;
            }
        });
    });
            
    // ]]>
</script>





<div id="novoDiv" title="Criar novo utilizador">
    <div id="novoDivMsgBox"></div>
    <fieldset id="novoFieldset">
        <form id="novoForm" action='{$base_url}utilizador/novo' method='post'>

            <p>
                <label for="utilizador">Utilizador</label>
                <input type="text" id="utilizador" name="utilizador" value="" />
            </p>
            <p>
                <label for="password">Password</label>
                <input type="password" id="password" name="password" value="" />

            </p>
            <p>
                <label for="password2">Password*</label>
                <input type="password" id="password2" name="password2" value="" />

            </p>

            <p>
                <select name="tipo" id="tipo">
                    <option value="1">Utilizador</option>
                    <option value="2">Administrador</option>
                </select>
            </p>
            <p>
                <input type="submit" value="Adicionar" name="adicionar" id="adicionar" />  
            </p>
        </form> 
    </fieldset>
</div>

{if $vazio eq 0}
Lista de utilizadores esta vazia
{else}

<table id="rounded-corner" summary="2007 Major IT Companies' Profit">
    <thead>
        <tr>
            <th scope="col" class="rounded-company"></th>
            <th scope="col" class="rounded">Nome</th>
            <th scope="col" class="rounded">Tipo</th>
            <th scope="col" class="rounded">Grupo</th>
            <th scope="col" class="rounded">Edit</th>
            <th scope="col" class="rounded-q4">Delete</th>
        </tr>
    </thead>
    <tfoot>
        <tr>
            <td colspan="5" class="rounded-foot-left"><em>Fim</em></td>
            <td class="rounded-foot-right">&nbsp;</td>
        </tr>
    </tfoot>
    <tbody>
        {foreach from=$users key=myId item=i}
        <tr>
            <td><input type="checkbox" name="" /></td>
            <td>{$i.utilizador}</td>
            <td>{$i.tipo}</td>
            <td>0</td>

            <td><a href="#"><img src="{$template_url}/admin/images/user_edit.png" alt="" title="" border="0" /></a></td>
            <td><a href="#" class="ask"><img src="{$template_url}/admin/images/trash.png" alt="" title="" border="0" /></a></td>
        </tr>
        {/foreach}

    </tbody>
</table>
{/if}

<a id="novoUtilA" href="#" class="bt_green"><span class="bt_green_lft"></span><strong>Adicionar</strong><span class="bt_green_r"></span></a>
